package softtech.apps.callblocker;

import softtech.apps.utility.ApplicationConstants;
import softtech.apps.callblocker.adapter.AdapterCallModeDialog;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class ActivityCallSetting extends Activity{

	private static final String TAG = null;
	private ListView lv;
	private AdapterCallModeDialog adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_call_mode);
		
		this.setTitle(getResources().getString(R.string.setting_mode_call));

		Intent intent = getIntent();
		Bundle bundle =intent.getExtras();
		
		lv = (ListView) findViewById(R.id.lvModeCallInDialog);
		int modeCall = bundle.getInt("mode") &240;
		Log.i(TAG,"mode Call: "  +modeCall);
		adapter = new AdapterCallModeDialog(this, modeCall);
		lv.setAdapter(adapter);
		
		// click to choose call mode
		lv.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Intent i = new Intent();
				i.setAction(ApplicationConstants.BROADCAST_ACTION_CALL_SETTING);
				i.putExtra("mode", position + 1);
				i.addCategory(Intent.CATEGORY_DEFAULT);
				sendBroadcast(i);
				ActivityCallSetting.this.finish();
			}
		});
		
	}
}
